package patterns.command;

import System.Task.Task;

public class EmergencyStopCommand implements MachineCommand {
        private Task task;
        private String reason;

    public EmergencyStopCommand(Task task, String reason) {
            this.task = task;
            this.reason = reason;
        }

        @Override
        public void execute() {
            task.addCommand("紧急停止! 原因: " + reason);
            task.fail("紧急停止: " + reason);
            System.out.println("执行: " + getDescription());
            // 发送紧急停止信号到农机
        }

        @Override
        public void undo() {
            System.out.println("警告: 紧急停止操作无法撤销");
        }

        @Override
        public String getDescription() {
            return "紧急停止任务 " + task.getTaskId() + ", 原因: " + reason;
        }
    }